FROM node:22-alpine3.21 AS frontend-builder
# 设置工作目录
WORKDIR /app
# 拷贝文件
# COPY 默认是源码路径 /app 
# package.json package-lock.json
COPY package*.json ./
RUN npm install 
COPY . .
RUN npm run build
# 得到dist
FROM nginx:alpine AS fronend-runtime

COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf
COPY --from=frontend-builder /app/dist /usr/share/nginx/html

# Expose port 80
EXPOSE 80
# 启动nginx
CMD ["nginx", "-g", "daemon off;"]